/*
 *    Copyright 2010-2013 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.mybatis.jpetstore.web.bean;

import org.mybatis.jpetstore.domain.Account;
import org.mybatis.jpetstore.domain.Product;

import java.io.Serializable;
import java.util.List;

/**
 * @author Eduardo Macarron
 */
public class AccountBean  implements Serializable {

	private static final long serialVersionUID = 5499663666155758178L;

	public AccountBean() {

	}

	public AccountBean(Account account, boolean authenticated, List<Product> myList) {
		this.account = account;
		this.authenticated = authenticated;
		this.myList = myList;
	}
	private String repeatedPassword;
	private Account account = new Account();
	private List<Product> myList;
	private boolean authenticated;

	public void setAccount(Account account) {
		this.account = account;
	}

	public void setAuthenticated(boolean authenticated) {
		this.authenticated = authenticated;
	}

	public Account getAccount() {
		return this.account;
	}

	public String getUsername() {
		return account.getUsername();
	}

	public String getPassword() {
		return account.getPassword();
	}

	public List<Product> getMyList() {
		return myList;
	}

	public void setMyList(List<Product> myList) {
		this.myList = myList;
	}

	public boolean isAuthenticated() {
		return authenticated && account != null && account.getUsername() != null;
	}

	public void clear() {
		account = new Account();
		myList = null;
		authenticated = false;
		repeatedPassword = null;
	}

	public String getRepeatedPassword() {
		return repeatedPassword;
	}

	public void setRepeatedPassword(String repeatedPassword) {
		this.repeatedPassword = repeatedPassword;
	}
}
